package com.snopzyz.hello.databus.enums;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ColumnKeyType {

    PRIMARY("PRI", "主键"),
    UNIQUE("UNI", "唯一索引"),
    MULTIPLE("MUL", "普通索引"),
    NONE("", "无索引");

    private final String code;
    private final String desc;


    public static ColumnKeyType fromCode(String code) {
        if (code == null) {
            return NONE;
        }
        for (ColumnKeyType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return NONE;
    }

}
